﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Player : MonoBehaviour {
	Rigidbody rigid;
	public float speed = 5;
	public Text scoreTxt;
	public int score = 0;

	// Use this for initialization
	void Start () {
		rigid = GetComponent<Rigidbody>();	
	}
	
	// Update is called once per frame
	void Update () {
		float h = Input.GetAxis ("Horizontal");
		float v = Input.GetAxis ("Vertical");

		Vector3 move = new Vector3 (h, 0, v);

		rigid.AddForce (move * speed);
	}

	public void AddScore(int n) {
		score += 1;
		scoreTxt.text = "分数：" + score;
	}
}
